package jbl.action;

import jbl.pageModel.UserGroup;
import jbl.service.UserGroupServiceI;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ModelDriven;

/**
 * @author jblcxg
 * 
 * 用户组管理  管理员可根据此类的来添加用户的不同权限
 *
 */
@Namespace("/")
@Action(value="userGroupAction")
public class UsergroupAction extends BaseAction  implements ModelDriven<UserGroup>{
	private UserGroupServiceI userGroupService;
	private UserGroup userGroup = new UserGroup();
	
	public UserGroup getUserGroup() {
		return userGroup;
	}
	
	@Override
	public UserGroup getModel() {
		return userGroup;
	}
	

	public UserGroupServiceI getUserGroupService() {
		return userGroupService;
	}
	@Autowired
	public void setUserGroupService(UserGroupServiceI userGroupService) {
		this.userGroupService = userGroupService;
	}
	
	/**
	 * 获取用户组信息  不分页
	 */
	public void dataGrid(){
		super.writeJson(userGroupService.showUserGroupList());	//发送到前端页面
	}

	/**
	 * 删除用户组
	 */
	public void deleteUserGroup(){
		writeJson(userGroupService.deleteUserGroup(userGroup.getIds()));//更新到前端页面
	}
	
	/**
	 * 修改用户组
	 */
	public void edit(){
		writeJson(userGroupService.editUserGroup(userGroup));//更新前端页面
		
	}
	
	/**
	 * 添加用户组
	 */
	public void add(){
		writeJson(userGroupService.addUserGroup(userGroup));
	}
	
	/**
	 * 获取用户组信息  combobox的下拉列表值
	 */
	public void comboboxInfo(){
		writeJson(userGroupService.comboboxInfo());
	}
}
